package cn.wei.reallyenjoy.comment.service.impl;


import cn.wei.reallyenjoy.comment.mapper.CommentsMapper;
import cn.wei.reallyenjoy.comment.pojo.vo.CommentVO;
import cn.wei.reallyenjoy.comment.pojo.vo.DiaryCommentVO;
import cn.wei.reallyenjoy.comment.service.CommentsService;
import cn.wei.reallyenjoy.common.entity.Comments;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 评论表 服务实现类
 * </p>
 *
 * @author Wei
 * @since 2021-11-28
 */
@Service
public class CommentsServiceImpl extends ServiceImpl<CommentsMapper, Comments> implements CommentsService {

    @Override
    public List<DiaryCommentVO> getCommentsByDiaryId(Long diaryId) {

        return baseMapper.getCommentsByDiaryId(diaryId);
    }

    @Override
    public void userCommentDiary(CommentVO commentVO) {
        Comments comments = new Comments();
        comments.setDiaryId(commentVO.getDiaryId());
        comments.setUserId(commentVO.getUserId());
        comments.setBody(commentVO.getBody());
        baseMapper.insert(comments);
    }
}
